package com.dg11185.nearshop.net.entity;

import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 商家评论实体类
 * 
 * @author：Daibo
 * @time：2014-5-16 上午9:03:58
 */
public class Comment implements Parcelable {

    public String commentId = "";

    public String createTime = "";

    public String title = "";

    public String content = "";

    public String userId = "";

    public String userName = "";

    public String headPhoto = "";

    public String merchantId = "";

    public String starRating = "";

    public String tasteEvaluation = "";

    public String environmentalAssessment = "";

    public String serviceEvaluation = "";

    public String totalLikes = "";

    public String totalComments = "";

    public String remark = "";

    public void parseEntity(JSONObject object) {

        commentId = object.optString("commentId");
        createTime = object.optString("createTime");
        title = object.optString("title");
        content = object.optString("content");
        userId = object.optString("userId");
        userName = object.optString("userName");
        headPhoto = object.optString("headPhoto");
        merchantId = object.optString("merchantId");
        starRating = object.optString("starRating");
        tasteEvaluation = object.optString("tasteEvaluation");
        environmentalAssessment = object.optString("environmentalAssessment");
        serviceEvaluation = object.optString("serviceEvaluation");
        totalLikes = object.optString("totalLikes");
        totalComments = object.optString("totalComments");
        remark = object.optString("remark");
    }

    public Comment() {

    }

    public Comment(Parcel in) {
        String[] data = new String[15];
        in.readStringArray(data);
        this.commentId = data[0];
        this.createTime = data[1];
        this.title = data[2];
        this.content = data[3];
        this.userId = data[4];
        this.userName = data[5];
        this.headPhoto = data[6];
        this.merchantId = data[7];
        this.starRating = data[8];
        this.tasteEvaluation = data[9];
        this.environmentalAssessment = data[10];
        this.serviceEvaluation = data[11];
        this.totalLikes = data[12];
        this.totalComments = data[13];
        this.remark = data[14];
    }

    public static final Parcelable.Creator<Comment> CREATOR = new Creator<Comment>() {

        @Override
        public Comment createFromParcel(Parcel source) {
            return new Comment(source);
        }

        @Override
        public Comment[] newArray(int size) {
            return new Comment[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStringArray(new String[] { this.commentId, this.createTime, this.title, this.content, this.userId,
                this.userName, this.headPhoto, this.merchantId, this.starRating, this.tasteEvaluation,
                this.environmentalAssessment, this.serviceEvaluation, this.totalLikes, this.totalComments, this.remark });
    }
}
